<template>
  <div>
    <def-layout type="col0-24" :page="page" @invoke="invoke">
      <div slot="search" class="form-items">
        <el-form-item>
          <form-remote-select
            v-model="formSearch.parentId"
            placeholder="纸厂"
            :url="service.conf.api.get('wms').url+'/api/logistics/location/map'"
          />
        </el-form-item>
        <el-form-item>
          <el-date-picker
            v-model="formSearch.createDate"
            type="daterange"
            align="right"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
            :picker-options="$constants.pickerOptions"
          />
        </el-form-item>
      </div>
      <div slot="content" class="grid">
        <page-grid v-if="self!=null" :parent="self">
          <div slot="columns">
            <el-table-column prop="parentName" align="center" label="供应商" width="200" />
            <el-table-column prop="orderSales" sortable align="right" label="供货金额" width="150" />
            <el-table-column prop="orderWeight" sortable align="right" label="供货重量(吨)" width="150" />
            <el-table-column prop="orderCount" sortable align="right" label="供货次数" width="150" />
            <el-table-column prop="orderPayment" sortable align="right" label="已付货款" width="150" />
            <el-table-column prop="returnCount" sortable align="right" label="退货次数" width="150" />
          </div>
        </page-grid>
      </div>
    </def-layout>

  </div>
</template>
<script>
import adminSupport from 'lola-admin-support-el'

export default {
  name: 'DestinationTopManage',
  components: {
  },
  mixins: [adminSupport.mixins.index],
  data() {
    return {
      name: 'DestinationTopManage',
      formSearch: { parentId: '', createDate: [] },
      self: null
    }
  },
  created() {
    this.init()// 页面自定义初始化
  },
  methods: {
    init() {
      var that = this
      this.dataGrid.params.sortFields = 'orderSales_d'
      // Excel导出配置
      this.page.excelParams = {
        fileds: ['parentName', 'orderSales', 'orderWeight', 'orderCount', 'orderPayment', 'orderPayment', 'returnCount'],
        queryParam: this.dataGrid.params,
        size: 10000
      }
      that.loadData()// 加载数据(按钮+列表) 扩展需重写该方法
      this.self = that
      this.dataGrid.table.tool = false
    },
    search() {
      const queryList = []
      if (!String.isNullOrEmpty(this.formSearch.parentId)) {
        queryList.push({ 'key': 'o.parentId', 'value': this.formSearch.parentId, 'oper': '=', 'join': 'and' })
      }
      if (this.formSearch.createDate !== null && this.formSearch.createDate.length > 0) {
        queryList.push({ 'key': 'o.createDate', 'value': this.formSearch.createDate[0], 'oper': '>=', 'join': 'and' })
        queryList.push({ 'key': 'o.createDate', 'value': this.formSearch.createDate[1], 'oper': '<=', 'join': 'and' })
      }
      this.dataGrid.params.queryList = queryList
      this.refresh()
    },
    bindSearch() {
      this.formSearch = { parentId: '', createDate: [] }
    }
  }
}
</script>
